home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1996 September / JCSM Shareware Collection (JCS Distribution) (September 1996).ISO / bother__ / cenvid.zip / CENVIDOS.ZIP / DOSINTR.LIB < prev    next >
Text File  |  1995-03-14  |  4KB  |  124 lines

  1. // DosIntr.lib - Dos interrupt calls.  These functions are provide
  2. // ver.5         interfaces to some of the low-level DOS calls.
  3. //               This library can be used with CEnvi for DOS or
  4. //               CEnvi for Windows.
  5. //
  6. //**** CreateDirectory(): Create a directory
  7. // SYNTAX: bool CreateDirectory(string DirectorySpec)
  8. // WHERE: DirectorySpec is the name of the directory to create
  9. // RETURN: Return False if error (cannot create or already exists)
  10. // EXAMPLE: CreateDirectory("C:\\TESTDIR");
  11. // NOTE: Use Directory() function to test if directory exists
  12. //
  13. //**** DeleteDirectory(): Delete a directory
  14. // SYNTAX: bool DeleteDirectory(string DirectorySpec)
  15. // WHERE: DirectorySpec is the name of the directory to delete
  16. // RETURN: Return False if error (cannot delete or no directory exists)
  17. // EXAMPLE: DeleteDirectory("C:\\TESTDIR");
  18. //
  19. //**** SetCurrentDirectory(): Change drive to different directory
  20. // SYNTAX: bool SetCurrentDirectory(string DirectorySpec)
  21. // WHERE: DirectorySpec is the name of an existing directory
  22. // RETURN: Return False if error
  23. // EXAMPLE: SetCurrentDirectory("C:\\TESTDIR");
  24. // NOTE: If DirectorySpec includes drive letter, then will not change
  25. //       current drive to that drive; see SetCurrentDrive().  For
  26. //       getting current directory use FullPath(".")
  27. //
  28. //**** SetCurrentDrive(): Change to a different drive letter
  29. // SYNTAX: bool SetCurrentDirectory(char DriveLetter)
  30. // WHERE: DriveLetter is character drive letter to change to
  31. // RETURN: Return False if unable to change to drive letter
  32. // EXAMPLE: SetCurrentDrive('C');
  33. // NOTE: Current drive letter is FullPath(".")[0]
  34. //
  35. //**** SetFileAttributes(): Set File Attributes
  36. // SYNTAX: bool SetFileAttributes(string FileName,int Attributes)
  37. // WHERE: FileName: name of existing file
  38. //        Atrribute: OR of flags as defined in the Directory() function
  39. // RETURN: Return false for failure
  40. // NOTE: Use Directory() to read file attributes; this call does not
  41. //       access volumes or subdirectories; Normal attribute is 0
  42. //
  43. //**** SetFileDateAndTime(): set time and date of last write
  44. // SYNTAX: bool SetFileDateAndTime(string FileName,int Time)
  45. // WHERE: FileName: name of existing file
  46. //        Time: as returned by the time() call or by Directory()
  47. // RETURN: Return false for failure
  48. //
  49.  
  50. CreateDirectory(pDirSpec)
  51. {
  52.    lReg.ah = 0x39;
  53.    lReg.ds = segment(pDirSpec);
  54.    lREg.dx = offset(pDirSpec);
  55.    return interrupt(0x21,lReg);
  56. }
  57.  
  58. DeleteDirectory(pDirSpec)
  59. {
  60.    lReg.ah = 0x3A;
  61.    lReg.ds = segment(pDirSpec);
  62.    lREg.dx = offset(pDirSpec);
  63.    return interrupt(0x21,lReg);
  64. }
  65.  
  66. SetCurrentDirectory(pDirSpec)
  67. {
  68.    lReg.ah = 0x3B;
  69.    lReg.ds = segment(pDirSpec);
  70.    lReg.dx = offset(pDirSpec);
  71.    return interrupt(0x21,lReg);
  72. }
  73.  
  74. SetCurrentDrive(pDriveLetter)
  75. {
  76.    lReg.ah = 0x0E;
  77.    lReg.dl = toupper(pDriveLetter) - 'A';
  78.    interrupt(0x21,lReg);
  79.    return ( (lFullP = FullPath(".")) && lFullP[0] == toupper(pDriveLetter) );
  80. }
  81.  
  82. SetFileAttributes(pFileName,pAttributes)
  83. {
  84.    lReg.ah = 0x43;
  85.    lReg.al = 1;
  86.    lReg.cx = pAttributes;
  87.    lReg.ds = segment(pFileName);
  88.    lReg.dx = offset(pFileName);
  89.    return interrupt(0x21,lReg);
  90. }
  91.  
  92. SetFileDateAndTime(pFileName,pTime)
  93. {
  94.    lSuccess = False;
  95.    // Open file to get a handle
  96.    lReg.ah = 0x3D;
  97.    lReg.al = 0x42;
  98.    lReg.ds = segment(pFileName);
  99.    lReg.dx = offset(pFileName);
  100.    if ( interrupt(0x21,lReg,lRegout) ) {
  101.       lHandle = lRegout.ax;
  102.       // write date to file
  103.       undefine(lReg);
  104.       lReg.ah = 0x57;
  105.       lReg.al = 1;
  106.       lReg.bx = lHandle;
  107.       lTm = localtime(pTime);
  108.       lReg.cx = (lTm.tm_sec / 2)
  109.               | (lTm.tm_min << 5)
  110.               | (lTm.tm_hour << 11);
  111.       lReg.dx = lTm.tm_mday
  112.               | ((lTm.tm_mon+1) << 5)
  113.               | ((lTm.tm_year-80) << 9);
  114.       lSuccess = interrupt(0x21,lReg);
  115.       // close file
  116.       undefine(lReg);
  117.       lReg.ah = 0x3E;
  118.       lReg.bx = lHandle;
  119.       interrupt(0x21,lReg);
  120.    }
  121.    return lSuccess;
  122. }
  123.  
  124.